<template>  
    <view>  
        <carHeader :title="'我的车辆'"></carHeader>  
        <uni-card v-if="size === 0" class="no-vehicle-card">  
            <view class="no-vehicle-content">  
                <view class="image-container">  
                    <image class="no-vehicle-image" src="/static/车联网服务-08我的-05我的车辆添加_slices/组 4.png"></image>  
                </view>  
                <view class="no-vehicle-text">暂无车辆信息</view>  
            </view>  
        </uni-card>  
  
        <view v-else class="vehicle-list">  
            <uni-card v-for="(item, index) in items" :key="item.chepai" class="vehicle-card">  
                <view class="vehicle-info">  
                    <view class="vehicle-image-container">  
                        <image class="vehicle-image" :src="item.Image"></image>  
                    </view>  
                    <view class="vehicle-details">  
                        <view class="vehicle-brand">车型：{{ item.brand }}</view>  
                        <view class="vehicle-license">车牌：{{ item.chepai }}</view>  
                    </view>  
                </view>  
				<view class="radio-container">
					<radio-group @change="handleRadioChange">
						<view class="radio-item">
							<radio :value="index.toString()" :checked="current === index" activeBackgroundColor="red" />
							<text>设为默认车辆</text>
						</view>
					</radio-group>
					<text>删除</text>
				</view>
			</uni-card>
		</view>

		<view class="button-container">
			<button @click="add">+ 添加车辆</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				size: 1,
				items: [{
						id: 1,
						Image: "/static/车联网服务-08我的-06我的车辆_slices/奔驰-GR.jpg",
						brand: "奔驰-GR",
						chepai: "豫M35468",
						checked: 'true'
					},
					{
						id: 2,
						Image: "/static/车联网服务-08我的-06我的车辆_slices/奔驰-GR.jpg",
						brand: "奔驰-GR",
						chepai: "豫M35422",
					}
				]
			}
		},
		methods: {
			handleRadioChange(e) {
				console.log(e);
				this.current = parseInt(e.detail.value); // 更新当前选中项  
			},
			add() {
				uni.navigateTo({
					url: '/pages/tianjiacheliang/tianjiacheliang'
				})
			},
		}
	}
</script>

<style lang="scss">
	.carHeader{
		background-size: cover;
	}
	.no-vehicle-card {  
	    position: relative;  
	    top: -180rpx;  
	}  
	  
	.no-vehicle-content {  
	   margin-top: 150rpx;
	   border-radius: 30rpx; 
	   height: 800rpx;
	}  
	.image-container{
		width: 90%;
		height: 380rpx;
	}
	.no-vehicle-image {  
	    width: 100%;  
	    height: 100%;  
	}  
	  
	.no-vehicle-text {  
	    text-align: center; 
		font-size: 28rpx; 
		color: #C4C4C4;
	}  
	  
	.vehicle-list {  
	    margin-top: -200rpx;  
	}  
	  
	.vehicle-card {  
	    border-radius: 20rpx;  
	}  
	  
	.vehicle-info {  
	    display: flex;  
	    align-items: center;  
	}  
	  
	.vehicle-image-container {  
	    width: 100rpx;  
	    height: 100rpx;  
	    border-radius: 50%;  
	    overflow: hidden;  
	    margin-right: 20rpx;  
	}  
	  
	.vehicle-image {  
	    width: 100%;  
	    height: 100%;  
	}  
	  
	.vehicle-details {  
	    font-size: 30rpx;  
	}  
	  
	.vehicle-brand {  
	    font-weight: bold;  
	    margin-bottom: 10rpx;  
	}  
	  
	.vehicle-license {  
	    color: #000;  
	}   
	.radio-container{
		margin-top: 80rpx; 
		display: flex; 
		justify-content: space-between;
	}
	.radio-item{
		display: flex; 
		align-items: center;
	}
	.button-container{
		position: absolute;
		bottom: 30rpx;
		width: 100%;
		button{
			color: #fff; 
			font-size: 30rpx; 
			text-align: center;
			width: 80%;
			background-color: #3384FC;
			border-radius: 100rpx;
		}
	}
</style>